package Util::QQBind::QQBind;
use Moose;
use namespace::autoclean;

has 'schema' => (
	is => 'rw',
	required => 1,
	isa => 'DBIx::Class::Schema',
);

sub is_bind{
	my ($self, $openId) = @_;

	return $self->schema->resultset('QQBind')->search({'openId' => $openId, 'status' => 'Y'},{});
}

sub find_bind_entries {
	my ($self, $openId) = @_;

	return $self->schema->resultset('QQBind')->search({'openId' => $openId, 'status' => 'N'},{});
}

sub get_bind{
	my ($self, $user_id) = @_;

	return $self->schema->resultset('QQBind')->search({'user_id' => $user_id},{});
}

sub bind_do{
	my ($self, $openId,  $user_id, $status) = @_;
        my $bind = $self->schema->resultset('QQBind')->create({
                        openId => $openId,
                        user_id => $user_id,
			status => $status
		});
}
__PACKAGE__->meta->make_immutable;

1;
